var pageii = null;
var grid = null;
if(interval!=null){
	clearInterval(interval);//取消定时器
}
$(function() {	
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "Mold_Number",
			name : "模具编号"
		},{
			colkey : "Clients",
			name : "客户"
		}, {
			colkey : "Molding_Cycle",
			name : "每模周期"
		},{
			colkey : "Standard_Capacity",
			name : "标准产能"
		},{
			colkey : "Suite",
			name : "套/件"
		},{
			colkey : "Price",
			name : "捡泡单件"
		},{
			colkey : "Pick_method",
			name : "捡泡方法"
		},{
			colkey : "remake",
			name : "备注"
			
		},{
			colkey : "status",
			name : "状态"
			
		},{
			colkey : "operation",
			name : "操作", 
			
		}],
		jsonUrl : rootPath + '/tryprice/pricing_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});

	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});

function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "修改产品定价参数",
		type : 2,
		area : [ "1200px", "100%" ],
		content : rootPath + '/tryprice/pricing_edit.shtml?id=' + cbox
	});
}

function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/tryprice/pricing_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}
	
